<%@ page language="java" pageEncoding="UTF-8"%>
<!doctype html>
<html lang="zh-CN">
<head>
<%@include file="/WEB-INF/views/commons/common.jsp"%>
<link rel="stylesheet" type="text/css" href="${base_href}/static/ui-frame/bootstrap/3.3.5/css/bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="${base_href}/static/ui-frame/bootstrap-dialog3/css/bootstrap-dialog.css">
<link rel="stylesheet" type="text/css" href="${base_href}/static/ui-frame/validation-engine/validationEngine.jquery.css">
<link rel="stylesheet" type="text/css" href="${base_href}/static/ui-frame/jquery-easyui/1.4.3/themes/metro/easyui.css">
<link rel="stylesheet" type="text/css" href="${base_href}/static/ui-frame/font-awesome/4.3.0/css/font-awesome.min.css">

<link rel="stylesheet" type="text/css" href="${base_href}/static/ui-frame/webuploader/0.1.5/webuploader.css">
<link rel="stylesheet" type="text/css" href="${base_href}/static/ui-frame/viewer/viewer.css">

<link rel="stylesheet" type="text/css" href="${base_href}/static/css/search-theme.css">
<link rel="stylesheet" type="text/css" href="${base_href}/static/css/form-theme.css">

<title>图书纠错详细信息</title>
</head>
<body data-spy="scroll" data-target="#myScrollspy" data-offset="350">

	<div class="main-wrap">

		<!-- 工具条 start-->
		<div class="container-fluid form-body-header">
			<div class="container">
				<div class="row tool-bar">
					<div class="col-xs-12">
						<button type="button" class="btn btn-sm tool-btn" id="saveBtn">保存</button>
						<button type="button" class="btn btn-sm tool-btn" id="submitBtn">确认发布</button>
					</div>
				</div>
			</div>
		</div>
		<!-- 工具条 end-->
		
		<!-- 表单 start-->
		<div class="container-fluid">
			<form id="form">
			
				<input type="hidden" name="question.quesId" value="${form.question.quesId }" />
				<input type="hidden" name="errorQuesAttach.quesId" value="${form.errorQuesAttach.quesId }" />
				
				<div class="container form-body-div">
					<div class="row text-center title-body" id="baseinfo">
						图书纠错收集页面<br />
					</div>
					<div class="row pannel-title">
						<span>联系方式</span> <a href="javascript:void(0);" class="hide-next-btn">收起</a>
					</div>
					<div class="row pannel-body">
						<table class="form-table">
							<tr>
								<th class="col-xs-2 ">姓名</th>
								<td class="col-xs-4" >
									${form.errorQuesAttach.submitterName}
								</td>
								<th class="col-xs-2 ">手机号</th>
								<td class="col-xs-4" >
									${form.errorQuesAttach.mobilePhone}
								</td>
							</tr>
							<tr>
								<th class="col-xs-2 ">电子邮箱</th>
								<td class="col-xs-4">
									${form.errorQuesAttach.email}
								</td>
								
								<th class="col-xs-2 ">支付宝账号</th>
								<td class="col-xs-4">
									${form.errorQuesAttach.alipayNum}
								</td>
							</tr>
						</table>
					</div>
					
					<div class="row pannel-title">
						<span id="errorinfo">纠错信息</span> <a href="javascript:void(0);"
							class="hide-next-btn">收起</a>
					</div>
					<div class="row pannel-body">
						<table class="form-table">
							<tr>
								<th class="col-xs-2 ">考试类别</th>
								<td class="col-xs-2">
									<c:forEach items="${quesBookClasses}" var="dic">
										<c:if test="${dic.code eq form.question.bookClass}">${dic.value}</c:if>
									</c:forEach> 
								</td>
								<th class="col-xs-2 ">图书名称</th>
								<td class="col-xs-6">
									<c:if test="${form.question.bookClass eq '1'}">
										<c:forEach items="${quesBookClasses1}" var="dic">
											<c:if test="${dic.code eq form.question.bookSecClass}">${dic.value}</c:if>
										</c:forEach> 
									</c:if>
									<c:if test="${form.question.bookClass eq '2'}">
										<c:forEach items="${quesBookClasses2}" var="dic">
											<c:if test="${dic.code eq form.question.bookSecClass}">${dic.value}</c:if>
										</c:forEach> 
									</c:if>
									<c:if test="${form.question.bookClass eq '3'}">
										<c:forEach items="${quesBookClasses3}" var="dic">
											<c:if test="${dic.code eq form.question.bookSecClass}">${dic.value}</c:if>
										</c:forEach> 
									</c:if>
									<c:if test="${form.question.bookClass eq '4'}">
										<c:forEach items="${quesBookClasses4}" var="dic">
											<c:if test="${dic.code eq form.question.bookSecClass}">${dic.value}</c:if>
										</c:forEach> 
									</c:if>
								</td>
							</tr>
							<tr>
								<th class="col-xs-2 ">图书页码</th>
								<td class="col-xs-4">
									${form.question.pageNum}
								</td>
								<th class="col-xs-2 "></th>
								<td class="col-xs-4">
								</td>
							</tr>
							<tr>
								<th class="col-xs-2 ">问题描述</th>
								<td class="col-xs-4" colspan="3">
									<div class="pre-div">${form.question.quesDescribe}</div>
								</td>
							</tr>
							<tr>
								<th class="col-xs-2 ">问题图片</th>
								<td class="col-xs-4" colspan="3">
									<table data-ms-class="attachment"
										class="attach-no-table upload-download-element" data-show-upload-button=false
										data-title="上传附件" data-is-readonly=true data-box-id="${form.question.quesId }"
										>
									</table>
								</td>
							</tr>
							<tr>
								<th class="col-xs-2 ">提出时间</th>
								<td colspan="3">
									<span style="float:right">
									<fmt:formatDate value="${form.question.quesTime}" type="both" pattern="yyyy-MM-dd HH:mm" />
									</span>
								</td>
							</tr>
						</table>
					</div>
					
					<div class="row pannel-title">
						<span id="teacherReply">教师答复</span> <a href="javascript:void(0);"
							class="hide-next-btn">收起</a>
					</div>
					<div class="row pannel-body">
						<table class="form-table">
							<tr>
								<th class="col-xs-2 ">问题难度</th>
								<td class="col-xs-4">
									<c:forEach items="${quesDiffLevels}" var="state">
										<c:if test="${state.code eq form.question.quesDiffLevel}">${state.value}</c:if>
									</c:forEach> 
								</td>
								<th class="col-xs-2 ">认领教师</th>
								<td class="col-xs-4">
									${form.question.claimUserName}
								</td>
							</tr>
							<tr>
								<th class="col-xs-2 " rowspan="2">回复</th>
								<td class="col-xs-10" colspan="4">
									<textarea class="form-control validate[maxSize[1000]]" 
										data-errormessage-range-overflow="回复内容不能超过1000个字" rows="5" 
										name="question.myAnwser" >${form.question.myAnwser}</textarea>
								</td>
							</tr>
							<tr>
								<td class="text-right col-xs-10" colspan="4">
									<button type="button" class="btn btn-sm tool-btn attach-upload">上传图片</button>
									<table data-ms-class="attachment"
										class="attach-no-table upload-download-element" data-show-upload-button=false
										data-title="上传附件" data-is-readonly=false data-box-id="${form.question.replyId }"
										>
									</table>
								</td>
							</tr>
							<tr>
								<th class="col-xs-2 ">回复时间</th>
								<td colspan="3">
									<span style="float:right">
									<fmt:formatDate value="${form.question.replyTime}" type="both" pattern="yyyy-MM-dd HH:mm" />
									</span>
								</td>
							</tr>
							<tr>
								<th class="col-xs-2 ">是否图书内容错误</th>
								<td colspan="4">
									<c:if test="${'0' eq form.errorQuesAttach.isError}">否</c:if>
									<c:if test="${'1' eq form.errorQuesAttach.isError}">是</c:if>
								</td>
							</tr>
						</table>
					</div>
					
					<div class="row pannel-title">
						<span id="adminApproval">管理员审批</span> <a href="javascript:void(0);"
							class="hide-next-btn">收起</a>
					</div>
					<div class="row pannel-body">
						<table class="form-table">
							<tr>
								<th class="col-xs-2 ">是否需要进行奖励</th>
								<td colspan="4">
									<select name="errorQuesAttach.isReward" class="form-control validate[required]" >
										<option value="" >请选择</option>
										<option value="0" <c:if test="${'0' eq form.errorQuesAttach.isReward}">selected="selected"</c:if>>否</option>
										<option value="1" <c:if test="${'1' eq form.errorQuesAttach.isReward}">selected="selected"</c:if>>是</option>
									</select>
								</td>
							</tr>
						</table>
					</div>
					
					<div class="row pannel-title">
						<span id="errorinfo">本书同页的问题</span> <a href="javascript:void(0);"
							class="hide-next-btn">收起</a>
					</div>
					<div class="row pannel-body">
						<table class="form-table">
							<c:forEach items="${repeatQuestions}" var="question">
								<tr>
									<td class="text-left col-xs-8" colspan="3">
										<a href="javascript:void(0);" class="red"
											onclick="exportFile('/quesList/openQuesReadPage.html?quesId=${question.quesId}')">
											${question.quesDescribe}
										</a>
									</td>
									<td class="text-center col-xs-2" >
										${question.quesType}
									</td>
									<td class="text-right col-xs-2" >
										<span style="float:right">
										<fmt:formatDate value="${question.quesTime}" type="both" pattern="yyyy-MM-dd HH:mm" />
										</span>
									</td>
								</tr>
							</c:forEach>
						</table>
					</div>
					
				</div>
			</form>
		</div>
		<!-- 表单 end-->
		
	</div>
	<script type="text/javascript" src="${base_href}/static/ui-frame/jquery/1.11.3/jquery.js"></script>
	<script type="text/javascript" src="${base_href}/static/ui-frame/bootstrap/3.3.5/js/bootstrap.js"></script>
	<script type="text/javascript" src="${base_href}/static/ui-frame/bootstrap-dialog3/js/bootstrap-dialog.js"></script>
	<script type="text/javascript" src="${base_href}/static/ui-frame/validation-engine/jquery.validationEngine-zh_CN.js"></script>
	<script type="text/javascript" src="${base_href}/static/ui-frame/validation-engine/jquery.validationEngine.js"></script>
	<script type="text/javascript" src="${base_href}/static/ui-frame/My97DatePicker/WdatePicker.js"></script>
	
	<script type="text/javascript" src="${base_href}/static/ui-frame/jquery-easyui/1.4.3/jquery.easyui.min.js"></script>
	<script type="text/javascript" src="${base_href}/static/ui-frame/jquery-easyui/1.4.3/easyui.util.js"></script>
	
	<script type="text/javascript" src="${base_href}/static/ui-frame/webuploader/0.1.5/mbs-upload.js"></script>
	<script type="text/javascript" src="${base_href}/static/ui-frame/viewer/viewer.js"></script>
	
	<script type="text/javascript">
		function exportFile(url) {
			url = basePath + url;
			var screenLocation = "width=960px,height=960,top=0,left=0,menubar=yes,resizable=yes,scrollbars =yes";
			window.open(url,"_blank",screenLocation,"详细信息");
		}
		$(function() {
			$('#form').validationEngine('attach', {
				maxErrorsPerField : 1,
				scroll : false,
				validationEventTrigger : "keyup blur change focus",
				ValidateNoneVisibleFields : true,//验证隐藏域
				promptPosition : "topRight" //验证弹出框的位置，topRight,topLeft,bottomRight,bottomLeft,centerRight,centerLeft,inline
			});

			$("#saveBtn").click(
				function() {
					$('a.hide-next-btn-show').each(
							function(i, val) {$(this).click();
							});
					if ($('#form').validationEngine('validate')) {
						return $.post(
									basePath+ "/external/errorCorrection/saveQuestion.json",
									$("#form").serialize(),
									function() {
										BootstrapDialog.alert("保存成功！")
									}, 'json');
					} else {
						return $.Deferred().reject('validatefail');
					}
				});
			$("#submitBtn").click(
					function() {
						$('a.hide-next-btn-show').each(function(i, val) {$(this).click();});
						if ($('#form').validationEngine('validate')) {
							return $.post(
										basePath+ "/external/errorCorrection/saveQuestion.json",
										$("#form").serialize(),
										function(r) {
											var ids =new Array();
											ids.push($("input[name='question.quesId']").val());
											$.ajax({
												url:  basePath+"/adminQuesList/publish.json?",
												type: "post",
												async: false, //不可异步,必须同步
												data:{ids: ids},
												traditional: true,
												dataType:"json",
												success: function(r){
													window.close();
													}
											})
											.fail(function() { BootstrapDialog.alert({title: "提示", message:"发布题目失败，请联系管理员。"});});
										}, 'json');
						} else {
							return $.Deferred().reject('validatefail');
						}
					});
			
			$(".attach-upload").click(function() {
				$(this).next().uploaddownload();
			});

			var quesBookClasses1;
			var quesBookClasses2;
			var quesBookClasses3;
			var quesBookClasses4;
			$.ajax({
				url : basePath + "/external/errorCorrection/getDicsByParam.json?model=ques_book_class_1",
				type : "get",
				async : false, //不可异步,必须同步
				dataType : "json",
				success : function(r) {
					quesBookClasses1 = r;
				}
			})
			$.ajax({
				url : basePath + "/external/errorCorrection/getDicsByParam.json?model=ques_book_class_2",
				type : "get",
				async : false, //不可异步,必须同步
				dataType : "json",
				success : function(r) {
					quesBookClasses2 = r;
				}
			})
			$.ajax({
				url : basePath + "/external/errorCorrection/getDicsByParam.json?model=ques_book_class_3",
				type : "get",
				async : false, //不可异步,必须同步
				dataType : "json",
				success : function(r) {
					quesBookClasses3 = r;
				}
			})
			$.ajax({
				url : basePath + "/external/errorCorrection/getDicsByParam.json?model=ques_book_class_4",
				type : "get",
				async : false, //不可异步,必须同步
				dataType : "json",
				success : function(r) {
					quesBookClasses4 = r;
				}
			})

			$("select[name='question.bookClass']").change(
				function() {
					var checkText = $(this).find("option:selected").text();
					var checkValue = $(this).val();
					if (checkValue == undefined || checkValue == null || checkValue == "") {
						$("select[name='question.bookSecClass']").empty();
						$("select[name='question.bookSecClass']").find("option").remove();
						return;
					}
					if (checkValue == 1) {
						$("select[name='question.bookSecClass']").empty();
						$("select[name='question.bookSecClass']").find("option").remove();

						for (var k = 0; k < quesBookClasses1.length; k++) {
							var option = "<option value='"+quesBookClasses1[k].code+"'>"
									+ quesBookClasses1[k].value
									+ "</option>";
							$("select[name='question.bookSecClass']").append(option);
						}
					}
					if (checkValue == 2) {
						$("select[name='question.bookSecClass']").empty();
						$("select[name='question.bookSecClass']").find("option").remove();
						for (var k = 0; k < quesBookClasses2.length; k++) {
							var option = "<option value='"+quesBookClasses2[k].code+"'>"
									+ quesBookClasses2[k].value
									+ "</option>";
							$("select[name='question.bookSecClass']").append(option);
						}
					}
					if (checkValue == 3) {
						$("select[name='question.bookSecClass']").empty();
						$("select[name='question.bookSecClass']").find("option").remove();
						for (var k = 0; k < quesBookClasses3.length; k++) {
							var option = "<option value='"+quesBookClasses3[k].code+"'>"
									+ quesBookClasses3[k].value
									+ "</option>";
							$("select[name='question.bookSecClass']").append(option);
						}
					}
					if (checkValue == 4) {
						$("select[name='question.bookSecClass']").empty();
						$("select[name='question.bookSecClass']").find("option").remove();
						for (var k = 0; k < quesBookClasses4.length; k++) {
							var option = "<option value='"+quesBookClasses4[k].code+"'>"
									+ quesBookClasses4[k].value
									+ "</option>";
							$("select[name='question.bookSecClass']").append(option);
						}
					}
				});
			
			$(document).on('click', 'img', function(){
				$(this).viewer();
			});
		});
	</script>
</body>
</html>
